package com.gewu.pm.ui.activity.order;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.ui.activity.filter.FilterMultipleActivity;
import com.gewu.pm.ui.fragment.PaymentFragment;
import com.hjq.base.FragmentPagerAdapter;

/**
 * 代支付页面
 */
public final class PendingPaymentActivity extends AppActivity {

    private XTabLayout mTabLayout;
    private ViewPager mViewPager;
    
    private FragmentPagerAdapter<AppFragment<?>> mPagerAdapter;

    public static void start(Context context) {
        Intent intent = new Intent(context, PendingPaymentActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_pending_payment;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mTabLayout = findViewById(R.id.tab_layout);
        mViewPager = findViewById(R.id.view_pager);
    }

    @Override
    protected void initData() {
        // 初始化 FragmentPagerAdapter
        mPagerAdapter = new FragmentPagerAdapter<>(this);
        mPagerAdapter.addFragment(PaymentFragment.newInstance(0), "先款后货");
        mPagerAdapter.addFragment(PaymentFragment.newInstance(1), "货到付款");
        mPagerAdapter.addFragment(PaymentFragment.newInstance(2), "账期非对公");
        mViewPager.setAdapter(mPagerAdapter);
        
        // 关联 XTabLayout 和 ViewPager
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public void onRightClick(View view) {// 跳转到筛选页面
        super.onRightClick(view);
        //FilterPendingPaymentActivity.start(getActivity());
        FilterMultipleActivity.start(this);
    }
}

